class EntityManager {
    private nextEntityId: number;
    private entities: Set<number>;

    constructor() {
        this.nextEntityId = 0;
        this.entities = new Set();
    }

    /**
     * 创建一个新的实体并返回其ID
     * @returns 新实体的ID
     */
    createEntity(): number {
        const entityId = this.nextEntityId++;
        this.entities.add(entityId);
        return entityId;
    }

    /**
     * 删除一个实体
     * @param entityId 要删除的实体的ID
     */
    destroyEntity(entityId: number): void {
        this.entities.delete(entityId);
    }

    /**
     * 检查实体是否存在
     * @param entityId 要检查的实体的ID
     * @returns 如果实体存在则返回true，否则返回false
     */
    hasEntity(entityId: number): boolean {
        return this.entities.has(entityId);
    }
}
